package testJdk.commonUse.enmu;

public class SeasonTest {
    public static void main(String[] args) {
        Season spring = Season.SPRING;
        System.out.println(spring);
        Season sunner = spring.SUNNER;
        System.out.println(sunner);
    }
}

//自定义枚举类
class Season {
    //1.Season对象的属性，不可变，不可被外界对象引用
    private final String seasonName;
    private final String description;

    //2.私有化类的构造器，这样才能保证类的对象不被外界创造
    private Season(String seasonName, String description) {
        this.seasonName = seasonName;
        this.description = description;
    }

    //3.创建当前枚举类的多个对象，这些对象对外公开，且不允许修改
    //设为静态成员变量，是为了在初始化类时，就加载出来
    public static final Season SPRING = new Season("春天", "万物复苏");
    public static final Season SUNNER = new Season("夏天", "阳光明媚");
    public static final Season AUTUMN = new Season("球天", "丰收时节");
    public static final Season WINTER = new Season("春天", "玩物蛰伏");

    //4.其他诉求：获取对象的属性
    public String getSeasonName() { return seasonName; }
    public String getDescription() { return description; }

    //5.提供打印方法
    @Override
    public String toString() {
        return "Season{" +
                "seasonName='" + seasonName + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}